package com.younion.common.base;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.younion.common.exception.BaseException;


public class BaseDAO extends SqlMapClientDaoSupport {

	protected List queryForList(String paramString, Object paramObject)
			throws BaseException {
		try {
			return super.getSqlMapClientTemplate().queryForList(paramString,
					paramObject);
		} catch (Exception localException) {
			throw new BaseException(localException);
		}
	}

	protected BaseVO queryForObject(String paramString, Object paramObject)
			throws BaseException {
		try {
			return (BaseVO) super.getSqlMapClientTemplate().queryForObject(
					paramString, paramObject);
		} catch (Exception localException) {
			throw new BaseException(localException);
		}
	}

	protected int queryCount(String paramString, Object paramObject)
			throws BaseException {
		try {
			return ((Integer) super.getSqlMapClientTemplate().queryForObject(
					paramString, paramObject)).intValue();
		} catch (Exception localException) {
			throw new BaseException(localException);
		}
	}

	protected List queryForPage(String paramString1, Object paramObject,
			int pageStartIndex, int pageSize) throws BaseException {
		List localList = null;
		try {
			localList = super.getSqlMapClientTemplate().queryForList(
					paramString1, paramObject, pageStartIndex, pageSize);
		} catch (Exception localException) {
			throw new BaseException(localException);
		}
		return localList;
	}

	protected Object insert(String paramString, Object paramObject)
			throws BaseException {
		try {
			super.getSqlMapClientTemplate().insert(paramString, paramObject);
			return paramObject;
		} catch (Exception localException) {
			throw new BaseException(localException);
		}
	}

	protected Object update(String paramString, Object paramObject)
			throws BaseException {
		try {
			super.getSqlMapClientTemplate().update(paramString, paramObject);
			return paramObject;
		} catch (Exception localException) {
			throw new BaseException(localException);
		}
	}

	protected int delete(String paramString, Object paramObject)
			throws BaseException {
		try {
			return super.getSqlMapClientTemplate().delete(paramString,
					paramObject);
		} catch (Exception localException) {
			throw new BaseException(localException);
		}
	}

}
